<%-- 
    Document   : studentHome
    Created on : 6 Apr, 2010, 1:55:43 PM
    Author     : Praveen Kumar
--%>

<%
String suid=(String)session.getAttribute("suid");
                if(suid==null||suid.equals(""))
                {
                        response.sendRedirect("../index.jsp");
                }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<%@page import="java.sql.*"%>
<%@page language="java" import="java.util.*"%>



<%

            String flag = null, msg=null;

            Connection connection = null;
            try {

                String driverName = "oracle.jdbc.driver.OracleDriver";
                Class.forName(driverName);

                // Create a connection to the database
                String serverName = "10.0.0.27";
                String portNumber = "1521";
                String sid = "XE";
                String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
                String uname = "aranya27";
                String pword = "doodledo";

                connection = DriverManager.getConnection(url, uname, pword);



              // enter code here

                Statement st = null;
                st = connection.createStatement();

                String str = "select * from aranya27.test_allot where suid=" + suid;
                ResultSet rs = st.executeQuery(str);
                if(rs.next())
                {
                    flag = rs.getString("flag");
                }
                if(flag.equals("0"))
                {
                    msg = "Your Details aren't complete. Please go to EditProfile to fill up the details. ";
                }
                else if(flag.equals("1"))
                {
                    msg = "Your Profile is complete. Please visit this page after allotment to view the results ! ";
                }
                else if(flag.equals("2"))
                {
                    msg = "Allotment is done ! The details are shown below. ";
                }
                else
                {
                    msg="something is worng !";
                }
%>

<html>
    <head>
        <style type="text/css">
            .tbl1
            {
                background: url('back.jpg');
                background-repeat: no-repeat;
            }
        </style>
        <title>HOME PAGE</title>
    </head>
    <body bgcolor="#6A6A6A" link="#CC0000" vlink="#CC0000" >
        <center>
            <table bgcolor="#E8E8E8" border="0" cellpadding="0" cellspacing="0" class="tbl1" width="782">
                <tr valign="top">
                    <td width="100%" height="91">
                    <img border="0" src="../images/back.jpg" width="782" height="159"></td>
                </tr>
                <tr><td bgcolor="#E8E8E8">&nbsp;</td></tr>
                <tr><td><table width="782"id="vista-buttons.com:idnvofc" width="0" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right:0px" title ="HOME                                            ">
                                    <a href="studentHome.jsp" onmouseover='xpe("nvofco");' onmouseout='xpe("nvofcn");'><img id="xpi_nvofc" src="btnvofc_0.png" name="vbnvofc" width="156" height="28" border="0" alt="HOME                                            " /></a></td><td style="padding-right:0px" title ="SAMPLE PROFILE                       ">
                                    <a href="sampleProfile.jsp" onmouseover='xpe("hvofco");' onmouseout='xpe("hvofcn");'><img id="xpi_hvofc" src="bthvofc_0.png" name="vbhvofc" width="156" height="28" border="0" alt="SAMPLE PROFILE                       " /></a></td><td style="padding-right:0px" title ="EDIT PROFILE                            ">
                                    <a href="editProfile.jsp" onmouseover='xpe("jvofco");' onmouseout='xpe("jvofcn");'><img id="xpi_jvofc" src="btjvofc_0.png" name="vbjvofc" width="156" height="28" border="0" alt="EDIT PROFILE                            " /></a></td><td style="padding-right:0px" title ="CHANGE PASSWORD                 ">
                                    <a href="../changePassword.jsp" onmouseover='xpe("kvofco")' onmouseout='xpe("kvofcn")'> <img id="xpi_kvofc" src="btkvofc_0.png"   name="vbkvofc" width="156" height="28" border="0" alt="CHANGE PASSWORD                 " /></a></td><td style="padding-right:0px" title ="LOGOUT                                     ">
                                    <a href="../logout.jsp" onmouseover='xpe("gvofco");' onmouseout='xpe("gvofcn");'><img id="xpi_gvofc" src="btgvofc_0.png" name="vbgvofc" width="156" height="28" border="0" alt="LOGOUT                                     " /></a></td></tr></table>
                    </td></tr>
                <tr>
                    <td bgcolor="#E8E8E8" valign="top" align="center">
                        <table bgcolor="#E8E8E8" width="90%">
                            <tr><td style="background-color: #E8E8E8;" >&nbsp;</td></tr>
                            <tr>

                                <td width="100%" align="center">
                                    <h1><font style="font-family: calibri; color: navy;">HOME PAGE</font></h1></td></tr>
                           
                <%
                if(flag.equals("0"))
                {
                    msg = "Your Details aren't complete. Please go to EditProfile to fill up the details. ";
                    %>
                    <tr><td><p align="center"><font style="font-family: calibri;color: navy;" > <%= msg %> </font></p>
                    <%
                }
                else if(flag.equals("1"))
                {
                    msg = "Your Profile is complete. Please visit this page after allotment to view the results ! ";
                    %>
                    <tr><td><p align="center"><font style="font-family: calibri;color: navy;" > <%= msg %> </font></p>
                    <%
                }
                else if(flag.equals("2"))
                {
                    msg = "Allotment is done ! The details are shown below. ";
                    
                    String str1 = "SELECT ROLLNO,BNAME,HOSTEL_ID,ROOM_ID FROM STUDENT_BRANCH_ROLL R1,ROOM_ALLOTMENTS R2,BRANCH_DETAILS R3 WHERE R1.SUID=" + suid + "AND R2.SUID=" + suid + " AND R3.BRANCHID=R1.BRANCHID" ;
                    ResultSet rs1 = st.executeQuery(str1);

                    if(rs1.next())
                        {
                            String bname = rs1.getString("bname");
                            String rollno = rs1.getString("rollno");
                            String hostelno = rs1.getString("hostel_id");
                            String roomno = rs1.getString("room_id");
                        


                    %>
                    <tr><td><p align="center"><font style="font-family: calibri;color: navy;" > <%= msg %> </font></p></td></tr>
                    <tr><td align="center" width="100%">
                            <table>
                                <tr><td align="left" width="50%">Branch      : </td><td align="center" width="50%"> <%= bname %> </td></tr>
                                <tr><td align="left" width="50%">Roll No.    : </td><td align="center" width="50%"> <%= rollno %> </td></tr>
                                <tr><td align="left" width="50%">Hall No.    : </td><td align="center" width="50%"> <%= hostelno %> </td></tr>
                                 <tr><td align="left" width="50%">Room No.    : </td><td align="center" width="50%"> <%= roomno %> </td></tr>
                            </table>
                    <% } %>
                    </td></tr>
                    <%
                }
               %>
                                
                        </table>

                    </td>
                </tr>
                <tr><td style="background-color: #E8E8E8;" >&nbsp;</td></tr>
                <tr><td style="background-color: #E8E8E8;" >&nbsp;</td></tr>
                <tr><td style="background-color: #E8E8E8;" >&nbsp;</td></tr>
                <tr><td style="background-color: #E8E8E8; width:425; height:73;" align="center" valign="middle"  style="line-height:22px"><font size="1"><a href="../about.jsp"> ABOUT US</a> | <a href="../developer.jsp">DEVELOPERS</a> | <a href="../contact.jsp">CONTACT US</a><br>

                    © ONLINE ADMISSION SYSTEM, NATIONAL INSTITUTE OF TECHNOLOGY, DURGAPUR<BR> E-MAIL: webmaster@admin.nitdgp.ac.in</font></td>
                </tr>
                <tr><td style="background-color: #E8E8E8;" >&nbsp;</td></tr>



            </table>
        </center>
    </body>
</html>

<%

                connection.close();


                //end here

            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                System.out.println(" Could not find the database driver");
            } catch (SQLException e) {
                e.printStackTrace();
                System.out.println("Could not connect to the database");
            }



%>